﻿using System;
using System.Globalization;

namespace Budget.Silver.Core.Extensions
{
    public static class DateTimeExtensions
    {
        public static int GetWeekNumber(this DateTime date)
        {
            return GetWeekNumber(date, CultureInfo.CurrentCulture);
        }

        public static int GetWeekNumber(this DateTime date, CultureInfo culture)
        {
            return culture.Calendar.GetWeekOfYear(date,
                                                  culture.DateTimeFormat.CalendarWeekRule,
                                                  culture.DateTimeFormat.FirstDayOfWeek);
        }
 
        public static int GetWeeksCount(this DateTime date)
        {
            return DateTime.DaysInMonth(date.Year, date.Month) / 7;
        }
    }
}